package com.hcc.gateway.domain.enums;

/**
 * ContentTypeEnum
 *
 * @author shengjun.hu
 * @date 2022/1/19
 */
public enum ContentTypeEnum {
    FORM_URLENCODED("application/x-www-form-urlencoded"),
    JSON("application/json"),
    XML("application/xml"),
    TEXT_PLAIN("text/plain"),
    TEXT_XML("text/xml"),
    TEXT_HTML("text/html"),
    OCTET_STREAM("application/octet-stream");

    private final String code;

    ContentTypeEnum(String code) {
        this.code = code;
    }

    public String getCode() {
        return code;
    }

    public boolean beContained(String contentType) {
        if (contentType == null) {
            return false;
        }

        return contentType.contains(this.getCode());
    }

}
